<!DOCTYPE >
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>基本设置</title>

  <link rel="stylesheet" type="text/css" href="/system/css/right.css">
  <script type="text/javascript" src="/system/js/jquery.js"></script>
  <script type="text/javascript" src="/system/js/system.js"></script>
  <script type="text/javascript" src="/system/js/admin.js"></script>


</head>
<body style="overflow: auto;">
	<div class="basic bor">
			<div class="title fl">当前位置：加盟商管理 > 添加会员</div>
			<div class="basic_r fr"><a href="">基本信息</a></div>
	</div>
	<div class="notice">
			<div class="n_title">
				<span class="fl">添加会员</span>

</div>
<div class="ncontent">
<form action="{:url('User/user_edit')}" method="post" enctype="multipart/form-data" >
	<div class="setting">
		<input type="hidden" name="id" value="{$detail.id??''}">

		<ul>

			<li>
				<dd class="setting_t fl"><span>*</span>用户名称 ：</dd>
				<dd class="setting_p fl"><input class="seinp" type="text" name="name" value="{$detail.name??""}">
					<!-- <span>产品名称不能为空</span> -->
				</dd>
			</li>

			<li>
				<dd class="setting_t fl"><span>*</span>用户账号 ：</dd>
				<dd class="setting_p fl">
				<input class="seinp" type="text" name="username" value="{$detail.username??''}" {if isset($detail['username'])} readonly{/if}>
					<span>用户账号不能修改</span>
				</dd>
			</li>

			<li>
				<dd class="setting_t fl"><span>*</span>手机号码 ：</dd>
				<dd class="setting_p fl"><input class="seinp" type="number" name="phone" value="{$detail.phone??''}">
					<!-- <span>产品名称不能为空</span> -->
				</dd>
			</li> 
          
			<li>
				<dd class="setting_t fl"><span>*</span>是否启用 ：</dd>
				<dd class="setting_p fl">
					{if isset($detail['enable'])}
				<label>
					<input name="enable" type="radio" {if condition="$detail['enable'] == 1"} checked="checked" {/if}  value="1">
				</label> 是
				<label><input name="enable" type="radio"  {if condition="$detail['enable'] == 0"} checked="checked" {/if} value="0"> 
				</label> 否 
				{else}
				<label>
				<input name="enable" type="radio"  checked="checked"  value="1">
				</label> 是
				<label><input name="enable" type="radio"  value="0"> 
				</label> 否 
				{/if}
				</dd>
			</li> 


			<li>
				<dd class="setting_t fl"><span>*</span>身份证号码 ：</dd>
				<dd class="setting_p fl">
				<input class="seinp" type="text" name="identify" value="{$detail.identify??''}" >
				<!-- <span>产品名称不能为空</span> -->
				</dd>
			</li>

			<li>
			<dd class="setting_t fl"><span>*</span>身份证正面 ：</dd>
			<dd class="setting_p fl colorfont">
			 <div class="infx" id="J_pic">
				<input class="infile " type="file" name="pic1" id="J_dy_img1"  >
				<span class="text_s">上传</span>
				</div>
				<div id="minpic1"> 
				{if isset($detail['identify_picp'])}
				  <a  class='liLabel' onclick='delpic(1)' num_id = '1' title='点击图片即可删除对应的身份证正面图片'  >
					<img src="{$detail.identify_picp??''}"  height='50px;' style='margin-left:10px;'> 
					<input class='infile' name='identify_picp' type='text' value="{$detail.identify_picp??''}" >
				  </a>
				  {/if}
				</div>
				</dd> 
		   </li>   
           <br/ >
            <li>
			<dd class="setting_t fl"><span>*</span>身份证正面 ：</dd>
			<dd class="setting_p fl colorfont">
			 <div class="infx" id="J_pic">
				<input class="infile " type="file" name="pic2" id="J_dy_img2" >
				<span class="text_s">上传</span>
				</div>
				<div id="minpic2"> 
				{if isset($detail['identify_picb'])}
				 <a class='liLabel' onclick='delpic(2)' num_id = '2' title='点击图片即可删除对应的身份证正面图片'  >
					<img src="{$detail.identify_picb??''}"  height='50px;' style='margin-left:10px;'> 
					<input class='infile' name='identify_picb' type='text' value="{$detail.identify_picb??''}" >
				  </a>
				  {/if}
				</div>
				</dd> 
		    </li>  

			<li>
				<dd class="setting_t fl"><span>*</span>地址 ：</dd>
				<dd class="setting_p fl">
					省份:
					<select  name="province" id="J_province" > 
						{volist name ='province_list' id = "li"}
						  {if isset($detail['province'])} 
						<option value="{$li.areaname}" {if $detail['province'] == $li['areaname']} 
						selected  data-id ="" {else} data-id ="{$li.rowid}" {/if}  >{$li.areaname}
						</option> 
						  {else}
	                        <option value="{$li.areaname}" data-id ="{$li.rowid}" >{$li.areaname}</option>
		                  {/if}

	                   {/volist}
					</select>城市:
					<select  name="city" id="J_city" >   
						 {if isset($detail['city']) }
						  <option value="" >{$detail.city}</option>
						 {/if}
					</select>
					区:<select  name="district" id="J_cdistrict" >  
						 {if isset($detail['district']) }
						  <option value="" >{$detail.district}</option>
						 {/if}
					</select>
				</dd>
				<dd class="setting_p fl">
			      详细地址:<input class="seinp" type="text" name="detail" value="{$detail.detail??''}" >
			   </dd>
			</li>
 

			<li>
				<dd class="setting_t fl"><span>*</span>加入费用 ：</dd>
				<dd class="setting_p fl"><input class="seinp" type="text" name="join_money" value="{$detail.join_money??''}" >
					<!-- <span>产品名称不能为空</span> -->
				</dd>
			</li>

			<li>
				<dd class="setting_t fl"> &nbsp;</dd>
				<dd class="setting_p fl">
                <input type="hidden" name="shop_id" value = "{$shop_id??''}">
                <input type="hidden" name="pid" value = "{$pid??''}">
				<input class="submit" type="submit" value="保存">

				</dd>
			</li>
		</ul>


	</div>
	</form>
</div>
	</div>
 </script>


<script type="text/javascript">

$(function(){
	 
	//上传图片
	$("#J_dy_img1").change(function(event) {
		var formData = new FormData();
		formData.append("file", $(this).get(0).files[0]);
		var name ="identify_picp";
		upload(formData,1,name);
	}); 

	//上传图片
	$("#J_dy_img2").change(function(event) {
		var formData = new FormData();
		formData.append("file", $(this).get(0).files[0]);
		var name ="identify_picb";
		upload(formData,2,name);
	}); 

	 var rowsid = $("#J_province option:selected").attr("data-id");
	 if(rowsid != ""){
	  getArea("060LVB","J_city")
	 }

	 //获取城市列表
	$("#J_province").change(function(){
       var rowid = $("#J_province option:selected").attr("data-id");
       getArea(rowid,"J_city")
	});

	$("#J_city").change(function(){
       var rowid = $("#J_city option:selected").attr("data-id");
       getArea(rowid,"J_cdistrict");
	});


});



function getArea(rowid,id){
	var data = {"rowid":rowid};
	$("#"+id).html("");
	$.ajax({
	 url:"{:url('User/getCityList')}",
	 type:'POST',
	 data:{"rowid":rowid}, 
	 dataType:'json',
	 success:function(res){   
		result = res.data;
		if(result.length>0){
			getArea(result[0]['rowid'],"J_cdistrict");
			for (var i = 0; i < result.length; i++) {
		       	var shtml = '<option value="'+result[i].areaname+'"   data-id ="'+result[i].rowid+'">'+result[i].areaname+'</option>';
		       	$("#"+id).append(shtml);
	        }
		}
	 }
	});
} 

function upload(data,id,name){
	$.ajax({
	 url:"{:url('User/ajaxuploads')}",
	 type:'POST',
	 data:data,
	 cache: false,
	 contentType: false,    //不可缺
	 processData: false,    //不可缺
	 success:function(data){
		 var res = JSON.parse(data);
		 html = "";
		 if(res.status == 1){
			 html = "<a  class='liLabel' onclick='delpic("+id+")' num_id = '"+id+"' title='点击图片即可删除对应的细节图片'  ><img src='"+res.path+"'  height='50px;' style='margin-left:10px;'> <input class='infile' name='"+name+"' type='text' value='"+res.path+"' ></a>";
			 $('#minpic'+id).append(html);
		 }else{
 			alert('参数错误！');
 			oBtn1.disabled = false;
		 }
	 }
	});
}

	//删除图片
	function delpic(id){
		var flag = confirm("确定删除吗?");
		if(!flag){
		  return false;
		}
		$('[num_id='+id+']').remove();

	}
</script>



</body>
</html>
